﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace DirectorySlicer
{
    /// <summary>
    /// represents/wraps one file. if size equals -1 after creation, then an error occured
    /// </summary>
    class FileContainer : IComparable
    {
        private String path;
        private long size = -1;

        public FileContainer(String path)
        {
            this.path = path;
            try
            {
                System.IO.FileInfo fi = new System.IO.FileInfo(path);
                this.size = fi.Length;
            }
            catch (Exception)
            {
                //just do nothing
            }
        }

        /// <summary>
        /// size on disk in byte
        /// </summary>
        /// <returns>size in byte></returns>
        public long getSize()
        {
            return size;
        }

        public String getLocation()
        {
            return path;
        }
        int IComparable.CompareTo(Object obj)
        {
            if (obj == this)
                return 0;
            FileContainer k = (FileContainer)obj;
            if (this.getSize() > k.getSize()) return -1;
            if (k.getSize() > this.getSize()) return 1;
            return 0;
        }
    }
}
